<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml"
      layout:decorator="share/adminPop">

<div layout:fragment="content">
    <form id="cate_save" class="form form-horizontal"> <!--enctype="multipart/form-data"-->
        <input type="hidden" name="id" th:value="${c.id}" />
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>名称：</label>
            <div class="formControls col-6">
                <input type="text" class="input-text" th:value="${c.name}"  name="name">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-3">上级分类：</label>
            <div class="formControls col-6">
                <select class="select select-box inline selparent" name="parentId" onchange="selChange(this)">
                    <option value="0" path="/0">--请选择</option>
                </select>
                <input type="hidden" id="parentIds" name="parentIds" th:value="${c.parentIds}"/>
            </div>
        </div>

        <div class="row cl">
            <div class="col-9 col-offset-2">
                <input class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">&nbsp;&nbsp;&nbsp;&nbsp;
                <button onclick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>

        </div>
            <!--<input type="hidden" id="scrollTop" name="scrollTop" />-->
    </form>
</div>
<script type="text/javascript" layout:fragment="scripts" th:inline="javascript">

     basicData.getCateTree('.selparent', '[[${c.parentId}]]');

    function selChange(sel){
        var opt = $(sel).find("option:selected");
        $("#parentIds").val(opt.attr("path")+'/'+ opt.val());
    }

    $('.btn-primary').click(function () {
       $lv.actionJson('/admin/videoCate/save', function (r) {
           if (r.code) {
               $lv.toast('成功！');
               //alert(parent.tb);
               parent.tb.fnDraw();
               layer_close();

           } else $lv.toast('no');
       }, 'cate_save');
    });
</script>